<?php
class Cms_View_Helper_HotJobs
{
    public $view;

    public function hotJobs()
    {
		$jobs = NULL;
		
		$query=new Doctrine_Query();
		$query->select('COUNT(v.job_id) as job_count,j.title,v.job_id,
						rjs.job_specialization_id,
						js.id,
						it.name')
			  ->from('ViewStatisticJob v')	
			  ->leftJoin('v.Job j')
			  ->leftJoin('j.ReferenceJobSpecialization rjs')
			  ->leftJoin('j.RefJob js')
			  ->leftJoin('js.IndustrieType it')
			  ->groupBy('it.id')
			  ->orderBy('job_count DESC');
			  
			 
		$result=$query->execute(array(1), Doctrine::FETCH_ARRAY);
		
		foreach($result as $hotjobs)
			$jobs[] = $hotjobs['Job']['RefJob'][0]['IndustrieType']['name'];
	
		return $jobs;
    }

    public function setView(Zend_View_Interface $view)
    {
        $this->view = $view;
    }
}
?>